<template>
  <el-button :type="btnType" @click="clickOpen">
    {{ btnText }}
  </el-button>
</template>

<script>
export default {
  props: {
    type: {
      type: String,
      default: 'warning'
    },
    name: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: '提示'
    },
    btnType: {
      type: String,
      default: 'text'
    },
    btnText: {
      type: String,
      default: '删除'
    }
  },
  methods: {
    clickOpen() {
      this.$confirm(`你确定要${this.btnText}${this.name ? `【${this.name}】` : ''}吗?`, this.title, {
        type: this.type
      }).then(() => {
        this.$emit('handleConfirm')
      }).catch(() => {
        this.$emit('handleCancel')
      })
    }
  }
}
</script>
